package me.shingohu.man.intergation;

import android.app.Activity;
import android.app.Application;
import android.view.MotionEvent;

import com.bugtags.library.Bugtags;
import com.bugtags.library.BugtagsOptions;

import me.shingohu.man.BuildConfig;

/**
 * Created by hujie on 17/4/14.
 */

public class BugtagsManager {

    //是否开启bugtags
    private static boolean openBugtags() {
        return BuildConfig.BUGTAG_OPEN;
    }
    private static boolean hasInit = false;


    public static void start(Application context) {
        if (openBugtags()) {
            BugtagsOptions.Builder builder = new BugtagsOptions.Builder();
            builder.trackingLocation(false);
            builder.startAsync(true);
            Bugtags.start(BuildConfig.BUGTAG_APPKEY, context, BuildConfig.BUGTAG_MODE, builder.build());
            hasInit = true;
        }
        
    }

    public static void onResume(Activity activity) {
        if (openBugtags() && hasInit) {
            //  Bugtags.onResume(activity);
            // OneApmAnalysis.onResume();
            Bugtags.onResume(activity);

        }
    }

    public static void onPause(Activity activity) {

        if (openBugtags() && hasInit) {
            Bugtags.onPause(activity);

        }
    }

    public static void onDispatchTouchEvent(Activity activity, MotionEvent event) {
        if (openBugtags() && hasInit) {
            Bugtags.onDispatchTouchEvent(activity, event);
        }
    }
}
